<{include file="header.html"}>
<script type="text/javascript">
function validate()
{
	document.booking_form.submit();
	return true;
}
function displayReason(rd){
	if(rd.value == 1){
		document.getElementById("REASON").style.display = "none";
	}
	else{
		document.getElementById("REASON").style.display = "block";
	}
}
function changeTechnician(bdID,technicianID){
	var agr = new Array();
	agr.push(bdID);
	agr.push(technicianID);
	var txt = callFunction('Technician::ajaxTechnicianList',agr);
	$("#techList_"+bdID).html(txt);
	document.getElementById("edit_"+bdID).style.display = "none";
	document.getElementById("update_"+bdID).style.display = "inline";
}
function cancelTechnician(bdID){
	document.getElementById("edit_"+bdID).style.display = "inline";
	document.getElementById("update_"+bdID).style.display = "none";
}
function updateTechnician(bdID){
	var agr = new Array();
	agr.push(bdID);
	agr.push(document.getElementById("technician_"+bdID).value);
	var txt = callFunction('Technician::updateTechnicianBooking',agr);
	if(txt != 'OK'){
		alert("There is an error while saving data. please try again");
		document.getElementById("edit_"+bdID).style.display = "none";
		document.getElementById("update_"+bdID).style.display = "inline";
		return false;
	}
	
	location.href = '<{$smarty.server.REQUEST_URI}>';
}
</script>
	<div class="box_home">
        <div class="box_content">
		<{assign var=user value=$bookingData.USER_INFO}>
		<{assign var=techData value=$bookingData.TDATA}>
		<form action="<{$smarty.server.REQUEST_URI}>" method="post" enctype="multipart/form-data"  name="booking_form">
		<input type="hidden" id="act" name="act" value="<{$smarty.const.ACT_VALID_EDIT}>"/>
		<table width="100%">
			<tr>
				<td width="20%"><{$smarty.const._LB_FIRST_NAME|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></td>
				<td colspan="3"><{$user.FIRST_NAME|utf8_escape_html}></td>
			</tr>
			<tr>
				<td ><{$smarty.const._LB_LAST_NAME|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></td>
				<td colspan="3"><{$user.LAST_NAME|utf8_escape_html}></td>
			</tr>
			<{if $g_user->isSupervisor()}>
			<tr>
				<td ><{$smarty.const._LB_EMAIL|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></td>
				<td colspan="3"><{$user.EMAIL|utf8_escape_html}></td>
			</tr>
			<tr>
				<td ><{$smarty.const._LB_TELEPHONE|utf8_escape_html}>&nbsp;:&nbsp;</td>
				<td colspan="3"><{$user.PHONE|utf8_escape_html}></td>
			</tr>
			<{/if}>
			<tr>
				<td colspan="4">
					<{foreach from=$techData key=techID item=data}>
					<{assign var=techTitle value=$data.TITLE}>
					<{assign var=sData value=$data.SDATA}>
					<table width="100%">
						<tr>
							<td style="width: 50%">
								<{$smarty.const._LB_TECHNICIAN|utf8_escape_html}>&nbsp;:&nbsp;
								<span id="edit_<{$techID}>" >
									<{if $data.TITLE != ""}>
									<{$data.TITLE|utf8_escape_html}>
									<{else}>
									<{$smarty.const._LB_NONE|utf8_escape_html}>
									<{/if}>
									<span><a href="#" onclick="changeTechnician(<{$techID}>,<{$data.ID_TECHNICIAN}>)"><{$html_input->image_tooltip("", $smarty.const._IMAGE_MODIFIER, $smarty.const.IMAGE_SIZE_SMALL, $smarty.const._LB_EDIT)}></a></span>
								</span>
								<span id="update_<{$techID}>" style="display: none">
									<span id="techList_<{$techID}>"></span>
									<a href="#" onclick="updateTechnician(<{$techID}>,<{$data.ID_TECHNICIAN}>)"><{$html_input->image_tooltip("", $smarty.const._IMAGE_DONE, $smarty.const.IMAGE_SIZE_SMALL, $smarty.const._LB_VALIDATE)}></a>
									<a href="#" onclick="cancelTechnician(<{$techID}>,<{$data.ID_TECHNICIAN}>)"><{$html_input->image_tooltip("", $smarty.const._IMAGE_SUPPRIMER, $smarty.const.IMAGE_SIZE_SMALL, $smarty.const._LB_CANCEL)}></a>
								</span>
								<br />
								<{$smarty.const._LB_BOOKING_DATE|utf8_escape_html}>&nbsp;:&nbsp;<{$data.BOOKING_DATE|date_format:"%d/%m/%Y %H:%M"}>
							</td>
							<td style="width: 50%">
								<{foreach from=$sData item=service}>
									<{$service.TITLE|utf8_escape_html}><br />
								<{/foreach}>
							</td>
						</tr>
					</table>
					<{/foreach}>
				</td>
			</tr>
			<tr>
				<td ><{$smarty.const._LB_CONFIRM|utf8_escape_html}>&nbsp;:&nbsp;</td>
				<td colspan="3">
					 
					<label ><input type="radio" value="1" name="STATUS" id="STATUS" onchange="displayReason(this)" /><{$smarty.const._LB_BOOKING_APPROVE|utf8_escape_html}></label><br />
					<label ><input type="radio" value="2" name="STATUS" id="STATUS" onchange="displayReason(this)" /><{$smarty.const._LB_BOOKING_REJECT|utf8_escape_html}></label><br />
					<textarea id="REASON" name="REASON" rows="5" cols="50" style="display: none"></textarea>
				</td>
			</tr>
			<tr>
				<td class="submit" colspan="4" style="padding-top:10px"><br />
					<a class="tribullet" href="<{$backlink}>"><{$smarty.const._LB_BACK}></a>
					<a class="tribullet" href="#" onclick="validate()"><{$smarty.const._LB_VALIDATE}></a>
				</td>
			</tr>
		</table>
		</form>
		</div>
	</div>
<{include file="footer.html"}>